package org.cuijq.thinking.in.spring.ioc.depencdeycy.injection;

import org.cuijq.thinking.in.spring.ioc.repository.UserRespository;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DependencyInjectionDemo {
    public static void main(String[] args) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/dependency-injection-context.xml");
        UserRespository userRepository = beanFactory.getBean("userRepository", UserRespository.class);
//        System.out.println(userRepository.getUsers());
        System.out.println(userRepository.getBeanFactory());

        System.out.println(beanFactory == userRepository.getBeanFactory());

        ObjectFactory userFactory = userRepository.getUserObjectFactorys();
        System.out.println(userFactory.getObject());

//        System.out.println(beanFactory.getBean(BeanFactory.class));
        System.out.println(userFactory.getObject()== beanFactory);
    }


}
